/**
 * $Id$
 *
 * Copyright (c) 2014 ChinaSoft International, Ltd. All rights reserved
 * JointForce Project
 *
 */
package com.csi.jf.crucible.api.util;

import com.chinasofti.ro.bizframework.core.libs.Base64;

/**
 * @Title: StringUtils.java
 * @Description: <br>
 *               <br>
 * @Company: Chinasofti
 * @Created on 2014-6-18 下午3:04:51
 * @author zhangmh
 * @version $Revision: 1.0 $
 * @since 1.0
 */
public class StringUtils {
    
    /**
     * Check a string if empty
     * @param s
     * @return
     */
    public static boolean isEmpty(String s){
        return s==null||"".equals(s.trim());
    }
    
    /**
     * get the substring from the "s" with the length "prefix"
     * @param s
     * @param prefix
     * @return
     * @Created on 2014-7-7 下午2:47:22
     * @author FengHaiBing
     */
    public static String getPrefix(String s, int prefix) {
    	if(s == null) return "";
    	
    	s = Chinese2PinYin.getPYString(s);
    	if(prefix > s.length()) return s;
    	
    	return s.substring(0, prefix - 1);
    }
    
    /**
     * replace the '@' with '%40'
     * 
     * @param s
     * @return
     * @Created on 2014-7-8 下午7:22:15
     * @author FengHaiBing
     */
    public static String replaceEmailAt(String s) {
    	if(s == null) return "";
    	return s.replace("@", "%40");
    }
    
    public static void main(String[] args) {
    	String s = "jfpts@chinasofti.com";
    	System.out.println(s);
    	System.out.println(replaceEmailAt(s));
    }

    public static boolean isNotBlank(String str) {
        return (str==null||str.trim().equals(""))?false:true;
    }

}
